package org.example.curriculum_design_6_16.common.handler;

import lombok.Data;

import org.example.curriculum_design_6_16.common.base.BaseException;
import java.time.Instant;

/**
 * 统一错误响应体
 */
@Data
public class ErrorResult {
    private final String code;
    private final String message;
    private final String detail;
    private final String path;
    private final long timestamp;

    public static ErrorResult of(BaseException ex, String path) {
        return new ErrorResult(
                ex.getErrorCode(),
                ex.getMessage(),
                ex.getDetail(),
                path,
                Instant.now().toEpochMilli()
        );
    }
}
